/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.skycloud.bts.webservice;

import com.skycloud.bts.service.TicketServiceRemote;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

/**
 * REST Web Service
 *
 * @author HAINN
 */
@Path("generic")
public class GenericResource {
    TicketServiceRemote ticketService = lookupTicketServiceRemote();

    /**
     * Creates a new instance of GenericResource
     */
    public GenericResource() {
    }

    /**
     * Retrieves representation of an instance of com.skycloud.bts.webservice.GenericResource
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("application/json")
    public String getJson() {
       return ticketService.testCount("HAI TEST: ");
    }

    /**
     * PUT method for updating or creating an instance of GenericResource
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("application/json")
    public void putJson(String content) {
    }

    private TicketServiceRemote lookupTicketServiceRemote() {
        try {
            javax.naming.Context c = new InitialContext();
            return (TicketServiceRemote) c.lookup("java:global/SkyBTSCore/SkyBTSCore-ejb/TicketService!com.skycloud.bts.service.TicketServiceRemote");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
